import type { CompanyInfoDto, EleSignInfoDto } from '@/api/company/types'
import TableRender, { type TableRenderColumnTypes } from '@/render/TableRender'
import toNative from '@/utils/toNative'
import { Component, Emit, Prop, Watch } from 'vue-facing-decorator'
import Drawer from '@/components/drawer/Index'

import BasicRule from './BasicRule'
import EmailRul from './EmailRule'
import ApiPushRule from './ApiPushRule'

@Component
export class DrawerAdd extends TableRender {
    @Prop() basicData!: EleSignInfoDto
    @Prop() show!: boolean

    showDrawer = false

    formData = {
        ruleName: '',
        insuranceProdcutId: 1,
        // 年龄规则
        age: {
            type: 1,
            min: '',
            max: ''
        },
        insurance: {
            type: '',
            value: ''
        },
        areaRule: {
            type: 1,
            client: [],
            company: []
        },
        validRule: {
            value: [],
        },
        feeDeduction: {
            value: []
        }
    }

    @Emit('update:show')
    updateShow(val: boolean) {
        return val
    }

    @Emit('refresh')
    refresh() {}

    @Watch('show', { immediate: true })
    handleWatchShow() {
        this.showDrawer = this.show
        if (this.showDrawer) {
            // this.getData()
        }
    }

    @Watch('showDrawer', { immediate: true })
    handleWatchShowDialog() {
        this.updateShow(this.showDrawer)
    }


    render() {
        return (
            <>
                <Drawer
                    v-model={this.showDrawer}
                    size={900}
                    title="推送规则"
                    resetStyle={true}
                    showClose
                    v-slots={{
                        default: () => {
                            return (
                                <div>
                                    <BasicRule />
                                    <EmailRul />
                                    <ApiPushRule />
                                </div>
                            )
                        }
                    }}
                ></Drawer>
            </>
        )
    }
}

export default toNative<{}, { refresh: () => void }>(DrawerAdd)
